{extend name='index@template/base'}{/extend}
{block name='style'}
<style>
    #table td {
        border-bottom: 1px solid #ddd;
    }

    .list_goods {
        list-style: none;
        margin: 0 0 5px;
        padding: 5px 0 0;
        font-size: 12px;
        width: 100%;
        height: 60px;
        box-sizing: content-box;
        border-top: 1px solid #ddd;
    }

    .list_goods:first-child {
        border-top: none;
    }

    .list_goods .img {
        float: left;
        width: 60px;
        height: 60px;
        text-align: center;
        line-height: 60px;
        margin-right: 15px;
        border: 1px solid #eee;
        box-sizing: border-box;
    }

    .list_goods .img img {
        max-width: 100%;
        max-height: 100%;
    }

    .list_goods .text {
        float: left;
        line-height: 25px;
        width: 300px;
    }

    .list_goods p {
        margin: 0;
    }

    .list_goods .price {
        float: left;
        line-height: 25px;
    }
</style>

<style>
    .cal {
        margin: 15px 15px 20px 15px
    }

    .info-box-icon {
        height: 57px;
        line-height: 57px;
    }

    .info-box {
        min-height: 58.5px;
        margin-bottom: 0;
        border: 1px solid #ccc;
    }
</style>
{/block}
{block name='script'}{/block}
{block name='content'}
<div class="row">
    <div class="col-xs-12">
        <div class="box-body">
            <div class="row">
                <div class="col-xs-3">
                    <div class="input-group col-xs-12">
                        <span class="input-group-addon">关键字</span>
                        <input type="text" class="form-control" id="keyword" placeholder="配送员"/>
                    </div>
                </div>

                <div class="col-xs-3">
                    <div class="input-group col-xs-12">
                        <span class="input-group-addon">时间</span>
                        <input class="form-control datetimepicker" type="text" name="begindate"
                               id="begindate" placeholder="起始日期"/>
                        <span class="input-group-addon" style="width:1em;">至</span>
                        <input class="form-control datetimepicker" type="text" name="enddate" id="enddate"
                               placeholder="截止日期"/>
                    </div>
                </div>
                <div class="col-xs-3">
                    <button type="button" class="btn btn-primary" id="btn_search"><i
                            class="glyphicon glyphicon-search"></i> 搜索
                    </button>
                </div>
            </div>
        </div>
    </div>
    <div class="col-xs-12">
        <div class="box-body">
            <div class="row">
                <!--<div class="col-xs-3">-->
                    <!--<button type="button" class="btn btn-primary" id="btn_search"><i-->
                            <!--class="glyphicon glyphicon-search"></i> 搜索-->
                    <!--</button>-->
                <!--</div>-->
            </div>

        </div>
    </div>
    <div class="col-xs-12">
        <div class="box">
            <div class="box-body">
                <table id="table"
                       data-toggle="table"
                       data-striped="true"
                       data-click-to-select="true"
                       data-query-params="requestParam"
                       data-side-pagination="server"
                       data-pagination="true"
                       data-id-field="id"
                       data-url="{:url('ShopOrder/summary_data')}"
                >
                    <thead>
                    <tr>
                        <!--<th data-field="id">ID</th>-->
                        <!--<th data-checkbox="true"></th>-->
                        <th data-field="name">配送员</th>
                        <th data-field="order_time" data-sortable="true">日期</th>
                        <th data-field="amount" data-formatter="formatPrice">日总金额</th>
                        <th data-field="status_text" data-formatter="formatStatus">状态</th>
                        <th data-field="flag_delivery" data-formatter="formatDelivery">方式</th>
                        <th data-field="operate" data-formatter="formatOperate" data-events="operateEvents">操作</th>
                    </tr>
                    </thead>
                </table>
            </div><!-- /.box-body -->
        </div><!-- /.box -->

    </div><!-- /.col -->
</div><!-- /.row -->
{/block}
{block name='script_extra'}
<script>
    var $table = $("#table");
    var $ids = "";
    var set_data_url = "{:url('ShopOrder/delivery_pay')}";
</script>
<script>
    $('.datetimepicker').datetimepicker({
        format: "Y-m-d",
        lang: 'ch',
        timepicker: false
    });
</script>
<script>
    // <editor-fold defaultstate="collapsed" desc="格式化url">
    function urlFormat(url) {
        if (url.indexOf('.html')) {
            url = url.replace('.html', '')
        }
        return url;
    }
    // </editor-fold>


    //搜索按钮事件
    $("#btn_search").on('click', function () {
        $('#table').bootstrapTable('refresh');
    })

    $("#sel_status").on('change', function () {
        $('#table').bootstrapTable('refresh');
    })

    $("#flag_delivery").on('change', function () {
        $('#table').bootstrapTable('refresh');
    })

    $("#flag_status").on('change', function () {
        $('#table').bootstrapTable('refresh');
    })


    var temp = {};
    function requestParam(params) {
        temp = {
            limit: params.limit, //页面大小
            offset: params.offset, //页码
            order: params.order,
            sort: params.sort,
            search: $("#keyword").val(),
            status: $("#sel_status").val(),
            flag_delivery: 0,
            flag_status: "1,7",
            begindate: $("#begindate").val(),
            enddate: $("#enddate").val(),
        };
        return temp;
    }


    // <editor-fold defaultstate="collapsed" desc="添加">
    $('#add_btn').on('click', function () {
        layer_open('添加', add_data_url)
    });
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="操作按钮">
    function formatOperate(value, row, index) {
        return [
            '<button class="btn btn-primary btn-sm row_set" href="javascript:void(0)">明细结算</button>&nbsp;',
        ].join('');
    }

    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="操作函数">
    window.operateEvents = {
        'click .row_set': function (e, value, row, index) {
//            console.log(row.da_id+"ss"+row.order_time);
            full_page(row.name,urlFormat(set_data_url)+"/da_id/"+row.da_id+"/order_time/"+row.order_time);
        }
    }

    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="支付方式">
    function formatDelivery(value) {
        switch (value) {
            case 0:
                return '<i class="fa text-yellow" title="在线支付">在线支付</i>';
                break;
            case 1:
                return '<i class="fa text-green" title="货到付款">货到付款</i>';
                break;
        }

    }
    // </editor-fold>
    // <editor-fold defaultstate="collapsed" desc="字段格式化">
    //格式下单用户
    function formatNick(value, e) {
        return e.o_name + '<br/>' + e.o_mobile;
    }
    //格式化价格
    function formatPrice(value) {
        return parseFloat(value).toFixed(2);
    }

    //格式化状态
    function formatStatus(value, e) {
        var status=e.flag_status;
        var class_name = '';
        if (status == '2' || status == '6') {
            class_name = ' bg-green';
        }
        if (status == '4') {
            class_name = ' bg-red';
        }
        if (status == '0') {
            class_name = ' bg-yellow';
        }
        return '<span class="badge' + class_name + '">' + value + '</span>';
    }
    // </editor-fold>

</script>
{/block}